/**
 * Created by Coing on 2017/2/26.
 */
public class Solution1 {

    public int lengthOfLastWord(String s) {

        if("".equals(s.trim()) || s.length() == 0){
            return 0;
        }
        // 分割
        String[] sarr = s.trim().split(" ");
        int sarr_len = sarr.length;
        int lenword = sarr[sarr_len-1].length();
        return lenword;
    }

    public static void main(String[] args) {
        Solution1 solution = new Solution1();
        System.out.println(solution.lengthOfLastWord(""));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("  "));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("hello world"));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("  lls  sd 32 "));

    }

}
